package com.zyht.website.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.wx.service.SysUserSecurityService;
import com.zyht.common.AbsManageBaseController;
import com.zyht.website.shiro.PermissionUtils;
import com.zyht.wechat.framework.env.WechatEnv;
 
@Controller
@RequestMapping("/admin")
public class AdminController extends AbsManageBaseController{
	
	@Resource
	private SysUserSecurityService sysUserSecurityService;

	@RequestMapping("/index")
	//@RequiresPermissions(value={"admin:index"})
	public  String index(HttpServletRequest request, Model m) {
		boolean isChange= sysUserSecurityService.checkChangePwd(PermissionUtils.getUser().getId());
		if(isChange){
			logger.info("用户密码已过期，跳转修改密码");
			m.addAttribute("msg", "温馨提示：您的密码使用时间已经超过120天，请尽快修改密码。");
			return "admin/auth/pwdindex";
		}
		
		if(!PermissionUtils.getSubject().isAuthenticated()){
			return "redirect:/admin/login";
		}
		
		//如果没有配置微信信息，跳转添加页面
		if(!WechatEnv.isWechatConfigOk()){
			return "forword:/admin/sysuser/toAdd.htm";
		}
		
		return "admin/index";
	}
}
